package com.js.springbootmongodb.service.Impl;

import com.js.springbootmongodb.entity.Comment;
import com.js.springbootmongodb.mapper.CommentMapper;
import com.js.springbootmongodb.service.CommentService;
import com.js.springbootmongodb.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    @Override
    public List<Comment> selectAll() {
        List<Comment> list = commentMapper.findAll();
        return list;
    }

    @Override
    public void add(Comment comment) {
        comment.setCreatedatetime(StringUtils.getNowTime());
        comment.setLikenum(9999);
        comment.setNickname("路飞");
        comment.setState(1);
        commentMapper.insert(comment);
    }


}
